home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / conv-rule-list-panel.xml < prev    next >
Extensible Markup Language  |  2010-01-15  |  6KB  |  208 lines

  1. <?xml version="1.0"?>
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  6.  
  7. <bindings xmlns="http://www.mozilla.org/xbl"
  8.     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  9.     xmlns:html="http://www.w3.org/1999/xhtml"
  10.     xmlns:xbl="http://www.mozilla.org/xbl">
  11.  
  12.     <binding id="ConvRuleListPanel" extends="widgets.xml#widget">
  13.  
  14.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  15.             <hbox flex="1">
  16.                 <vbox>
  17.                     <button anonid="xButNew" label="&button.conv-rule-list.new;" oncommand="this.parentNode.parentNode.parentNode.newRule()"/>
  18.                     <button anonid="xButEdit" label="&button.conv-rule-list.edit;" oncommand="this.parentNode.parentNode.parentNode.edit()"/>
  19.                     <button anonid="xButUp" label="&button.conv-rule-list.up;" oncommand="this.parentNode.parentNode.parentNode.move(true)"/>
  20.                     <button anonid="xButDown" label="&button.conv-rule-list.down;" oncommand="this.parentNode.parentNode.parentNode.move(false)"/>
  21.                     <button anonid="xButRemove" label="&button.conv-rule-list.remove;" oncommand="this.parentNode.parentNode.parentNode.remove()"/>
  22.                     <button anonid="xButDefault" label="&button.conv-rule-list.default;" oncommand="this.parentNode.parentNode.parentNode.revertDefault()"/>
  23.                 </vbox>
  24.                 <ConvRuleList anonid="xList" flex="1"/>
  25.             </hbox>
  26.             <children style="display: none;"/>
  27.         </xbl:content>
  28.  
  29.         <implementation>
  30.  
  31.             <constructor>
  32.                 <![CDATA[
  33. setTimeout(function(x) { x.updateControl(); },0,this);
  34.                 ]]>
  35.             </constructor>
  36.  
  37.             <method name="updateControl">
  38.                 <body>
  39.                 <![CDATA[
  40. var rule=this.xList.getSelectedRule();
  41. if(rule) {
  42.     this.xButRemove.setAttribute("hidden","false");
  43.     this.xButUp.setAttribute("hidden","false");
  44.     this.xButDown.setAttribute("hidden","false");
  45.     this.xButEdit.setAttribute("hidden","false");
  46. } else {
  47.     this.xButRemove.setAttribute("hidden","true");
  48.     this.xButUp.setAttribute("hidden","true");
  49.     this.xButDown.setAttribute("hidden","true");
  50.     this.xButEdit.setAttribute("hidden","true");
  51. }
  52.                 ]]>
  53.                 </body>
  54.             </method>
  55.  
  56.             <method name="edit">
  57.                 <body>
  58.                 <![CDATA[
  59. var rule=this.xList.getSelectedRule();
  60. if(rule) {
  61.     openDialog("chrome://dwhelper/content/conv-rule.xul","dwhelper-conv-rule","chrome,centerscreen,modal",
  62.         {
  63.             ref: rule,
  64.             datasource: this.xList.getDataSource()
  65.         });
  66.     this.fixOrder();
  67.     this.xList.select(rule);
  68. }
  69. window.sizeToContent();
  70.                 ]]>
  71.                 </body>
  72.             </method>
  73.  
  74.             <method name="newRule">
  75.                 <body>
  76.                 <![CDATA[
  77. var datasource=this.xList.getDataSource();
  78. var rule=this.convertMgr.makeDefaultRule(datasource);
  79. var data={
  80.     ref: rule,
  81.     datasource: datasource
  82. }
  83. openDialog("chrome://dwhelper/content/conv-rule.xul","dwhelper-conv-rule","chrome,centerscreen,modal",data);
  84. if(data.ok!=true)
  85.     this.util.removeReferenceS(datasource,rule);
  86. window.sizeToContent();
  87.                 ]]>
  88.                 </body>
  89.             </method>
  90.  
  91.             <method name="revertDefault">
  92.                 <body>
  93.                 <![CDATA[
  94. var r=confirm(this.util.getText("confirm.conv-rule.revert-default"));
  95. if(r==false)
  96.     return;
  97. var datasource=this.xList.getDataSource();
  98. this.convertMgr.makeDefaultDataSource(datasource);
  99. setTimeout(function(w) { w.sizeToContent(); },0,window);
  100.                 ]]>
  101.                 </body>
  102.             </method>
  103.  
  104.             <method name="remove">
  105.                 <body>
  106.                 <![CDATA[
  107. var rule=this.xList.getSelectedRule();
  108. if(rule) {
  109.     this.util.removeReferenceS(this.xList.getDataSource(),rule);
  110. }
  111. window.sizeToContent();
  112.                 ]]>
  113.                 </body>
  114.             </method>
  115.  
  116.  
  117.             <method name="fixOrder">
  118.                 <body>
  119.                 <![CDATA[
  120. var datasource=this.xList.getDataSource();
  121. var RDF = this.util.getRDF();
  122. datasource.beginUpdateBatch();
  123. var rootRes=RDF.GetResource("urn:root");
  124. for(var i=1;;i++) {
  125.     var propRes=RDF.GetResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#_"+i);
  126.     if(datasource.hasArcOut(rootRes,propRes)) {
  127.         var targetRes=datasource.GetTarget(rootRes,propRes,true);
  128.         datasource.Unassert(rootRes,propRes,targetRes);
  129.         datasource.Assert(rootRes,propRes,targetRes,true);
  130.     } else {
  131.         break;
  132.     }
  133. }
  134. datasource.endUpdateBatch();
  135.                 ]]>
  136.                 </body>
  137.             </method>
  138.  
  139.             <method name="move">
  140.                 <parameter name="up"/>
  141.                 <body>
  142.                 <![CDATA[
  143. var rule=this.xList.getSelectedRule();
  144. if(rule) {
  145.     var sibling=this.util.getChildResourcesS(this.xList.getDataSource(),"urn:root",{});
  146.     var index0=null;
  147.     var index1=null;
  148.     for(var i=0;i<sibling.length;i++) {
  149.         if(sibling[i].Value==rule) {
  150.             index0=i;
  151.             if(up && i>0)
  152.                 index1=i-1;
  153.             if(up==false && i<sibling.length-1)
  154.                 index1=i+1;
  155.             break;
  156.         }
  157.     }
  158.     if(index0==null || index1==null)
  159.         return;
  160.     var datasource=this.xList.getDataSource();
  161.     var RDF = this.util.getRDF();
  162.     datasource.beginUpdateBatch();
  163.     datasource.Change(RDF.GetResource("urn:root"),
  164.         RDF.GetResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#_"+(index0+1)),
  165.             sibling[index0],sibling[index1]);    
  166.     datasource.Change(RDF.GetResource("urn:root"),
  167.         RDF.GetResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#_"+(index1+1)),
  168.             sibling[index1],sibling[index0]);    
  169.     datasource.endUpdateBatch();
  170.     this.xList.select(rule);
  171. }
  172. window.sizeToContent();
  173.                 ]]>
  174.                 </body>
  175.             </method>
  176.  
  177.             <method name="save">
  178.                 <body>
  179.                 <![CDATA[
  180. this.convertMgr.setDataSource(this.xList.getDataSource());
  181.                 ]]>
  182.                 </body>
  183.             </method>
  184.  
  185.  
  186.         </implementation>
  187.         
  188.         <handlers>
  189.  
  190.             <handler event="RuleSelect">
  191.                 <![CDATA[
  192. this.updateControl();
  193. setTimeout(function(w) { w.sizeToContent(); },0,window);
  194.                 ]]>
  195.             </handler>
  196.  
  197.             <handler event="RuleDblClicked">
  198.                 <![CDATA[
  199. this.updateControl();
  200. this.edit();
  201.                 ]]>
  202.             </handler>
  203.         </handlers>
  204.  
  205.     </binding>
  206.  
  207. </bindings>
  208.